<template>
<div class="admin-edit-info">
	<Form ref="adminEdit" :model="detailInfo" :rules="adminValidate" action="javascript:void(0)">
		<FormItem label="姓名" prop="realname">
			<Input v-model="detailInfo.realname" placeholder="输入姓名..."></Input>
		</FormItem>
		<FormItem label="手机号">
			<Input v-model="detailInfo.phone" placeholder="输入手机号..."></Input>
		</FormItem>
		<FormItem label="邮箱">
			<Input v-model="detailInfo.email" placeholder="输入邮箱..."></Input>
		</FormItem>
		<FormItem>
			<Button type="primary" @click="handleSubmit('adminEdit')">提交</Button>
		</FormItem>
	</Form>
</div>
</template>


<script>
export default {
	name: 'AdminEditInfo',
	data() {
		return {
			detailInfo: {
				realname: '',
				phone: '',
				email: ''
			},
			adminValidate: {
				realname: [
					{ required: true, message: '姓名必须填写', trigger: 'blur' }
				]
			}
		}
	},
	created: function() {
		this.getInfo();
	},
	methods: {
		handleSubmit(name) {
			this.$refs[name].validate((valid) => {
				if (valid) {
					var params = this.detailInfo;
					params.id = this.$store.getters.user_id;
					this.$api.admin.selfeditinfo(params).then(res => {});
				}
			})
		},
		getInfo() {
			this.$api.admin.detail({ 'detailId': this.$store.getters.user_id }).then(res => {
                this.detailInfo = res.result
			});
		}
	}
}
</script>
